package org.restql.db.resource;

import java.sql.Connection;
import java.sql.SQLException;
import java.util.List;

import javax.sql.DataSource;

/**
 * Singleton that returns a new Connection object given an individual
 * request object.
 */
public interface DatabaseResource {
	
	public void setDataSource(DataSource dataSource);

	public void setDbName(String dbName);
	public String getDbName();

	public void setResourceName(String resourceName);
	public String getResourceName();

	public Connection getConnection(RequestResource requestResource) throws SQLException;

	public boolean allowSelect();
	public boolean allowUpdate();
	public boolean allowInsert();
	public boolean allowDelete();

	public String getSelectString(RequestResource resource, String max, String skip);
	public String getUpdateString(RequestResource resource, List<String> fieldList);
	public String getInsertString(RequestResource resource, List<String> fieldList, List<String> valuesList);
	public String getDeleteString(RequestResource resource);

	public void setJdbcUrl(String jdbcUrl);

	public void setJdbcDriver(String jdbcDriver);

	public void setUser(String user);

	public void setPassword(String password);

	public String getJdbcUrl();

	public String getJdbcDriver();

	public String getUser();

	public String getPassword();
}
